package com.rran.study.designpattern.behavioral.memento;

import lombok.Data;

/**
 * @author yy
 * @Type Originator.java
 * @Desc
 * @date 2020/7/24 12:29
 */
@Data
public class Originator implements MementoAction {

    public Originator(int gameLevel, Long blood) {
        this.gameLevel = gameLevel;
        this.blood = blood;
    }

    /**
     * 第几关
     */
    private int gameLevel;

    /**
     * 血量
     */
    private Long blood;

    @Override
    public Memento create() {
        Memento memento = new Memento();
        memento.setBlood(this.blood);
        memento.setGameLevel(this.gameLevel);
        return memento;
    }

    @Override
    public void load(Memento memento) {
        this.blood = memento.getBlood();
        this.gameLevel = memento.getGameLevel();
        System.out.println("读档成功");
    }
}
